<div class="offcanvas-header">
	<h6 class="text-white">
		<i class="bi bi-grid"></i>收款单据详情
	</h6>
	<i class="bi bi-x-square-fill" style="font-size: 1.5rem; color: #ffffff; cursor: pointer;" data-bs-dismiss="offcanvas" aria-label="Close"></i>
</div>
<div class="offcanvas-body pt-1">
	<div class="card">
		<div class="card-body" style="padding: 0.5rem 0.5rem;">
			<div class="row align-items-center">
				<div class="col">

					#if(receiptOrder.auditConfigFlag)
					#if(receiptOrder.order_status != OrderStatusEnum.disable.value)
					#if(receiptOrder.audit_status == AuditStatusEnum.waiting.value)
					#if(session.hasOper(Permissions.fund_book_receiptOrder_audit))
					<button type="button" class="btn btn-sm btn-outline-success" onclick="receiptOrder.audit(#(receiptOrder.id));">
					<i class="bi bi-hand-index"></i>审核
					</button> &nbsp;
					#end
					#end
					#end
					#end
					
					#if(!receiptOrder.auditConfigFlag || (receiptOrder.auditConfigFlag && (receiptOrder.audit_status != AuditStatusEnum.pass.value || session.hasOper(Permissions.fund_book_receiptOrder_audit))))
						#if(session.hasOper(Permissions.fund_book_receiptOrder_update))
						<button type="button" class="btn btn-sm btn-outline-primary" onclick="receiptOrder.edit(#(receiptOrder.id));">
							<i class="bi bi-pencil-square"></i>修改
						</button>&nbsp;
						#end 
					#end 
					#if(!receiptOrder.auditConfigFlag || (receiptOrder.auditConfigFlag && receiptOrder.audit_status != AuditStatusEnum.pass.value))
						#if(session.hasOper(Permissions.fund_book_receiptOrder_disable))
						<button type="button" class="btn btn-sm btn-outline-danger" onclick="receiptOrder.disable(#(receiptOrder.id));">
							<i class="bi bi-trash"></i>作废
						</button>&nbsp;
						#end 
					#end
					
					#if(receiptOrder.order_status == OrderStatusEnum.draft.value)
						#if(session.hasOper(Permissions.fund_book_receiptOrder_disable))
						<button type="button" class="btn btn-sm btn-outline-danger" onclick="receiptOrder.delete(#(receiptOrder.id));">
							<i class="bi bi-trash"></i>删除
						</button>&nbsp;
						#end 
					#end
				</div>
				
				<div class="col text-end">
					<button type="button" class="btn btn-sm btn-primary" onclick="receiptOrder.showPrint(#(receiptOrder.id));">
						<i class="bi bi-printer"></i>打印
					</button>
					#if(receiptOrder.print_count > 0)
					&nbsp; <span class="btn btn-sm btn-outline-danger sm-more">已打印:#(receiptOrder.print_count)</span>
					#end
				</div>
				
				#if(receiptOrder.order_status == OrderStatusEnum.disable.value)  
					<img src="#(resourceDomain)/img/disable.png" class="order-status-pic">
				#elseif(receiptOrder.audit_status == AuditStatusEnum.reject.value) 
					<img src="#(resourceDomain)/img/audit_reject.png" class="order-status-pic">
				#end
				 
			</div>
		</div>
	</div>
	
	<div id="receiptOrder_showDetail">
	<div class="card mt-2">
		<div class="card-body" style="padding: 1rem 1rem;">
			<div class="row">
				<div class="col-3">
					<span class="text-secondary">单据编号：</span><span>#(receiptOrder.order_code)</span>
				</div>
				<div class="col-3">
					<span class="text-secondary">客户：</span><span class="text-secondary fw-bold">#(receiptOrder.customerInfo.name??)</span>
				</div>
				<div class="col-3">
					<span class="text-secondary">单据日期：</span><span>#date(receiptOrder.order_time, "yyyy-MM-dd")</span>
				</div>
				
			</div>
			<hr class="row-hr" />
			<div class="row">
				<div class="col-3">
					<span class="text-secondary">经办人：</span><span>#(receiptOrder.handler.real_name??)</span>
				</div>
				<div class="col-3">
					<span class="text-secondary">制单人：</span><span>#(receiptOrder.makeMan.real_name??)</span>
				</div>
				<div class="col-3">
					<span class="text-secondary">制单时间：</span><span>#date(receiptOrder.created_at, "yyyy-MM-dd HH:mm:ss")</span>
				</div>
				<div class="col-3">
					<span class="text-secondary">最近修改：</span><span>#date(receiptOrder.updated_at, "yyyy-MM-dd HH:mm:ss")</span>
				</div>
			</div>
			
			#if(receiptOrder.auditConfigFlag)
			<hr class="row-hr" />
			<div class="row">
				<div class="col-3">
					<span class="text-secondary">审核状态：</span>
					#if(receiptOrder.audit_status == AuditStatusEnum.waiting.value) 
					<span class="badge bg-warning">待审核</span> 
					#elseif(receiptOrder.audit_status == AuditStatusEnum.pass.value) 
					<span class="badge bg-success">审核通过</span>  
					#elseif(receiptOrder.audit_status == AuditStatusEnum.reject.value) 
					<span class="badge bg-danger">审核拒绝</span>   
					#end
				</div>
				<div class="col-3">
					<span class="text-secondary">审核人：</span><span>#(receiptOrder.auditor.real_name??)</span>
				</div>
				<div class="col-3">
					<span class="text-secondary">审核时间：</span><span>#date(receiptOrder.audit_time, "yyyy-MM-dd HH:mm:ss")</span>
				</div>
				<div class="col-3">
					<span class="text-secondary">审核反馈：</span><span>#(receiptOrder.audit_desc)</span>
				</div>
			</div>
			#end
		</div>
	</div>
	
	<div class="row mt-3">
		<div class="col">
		<table class="table table-hover table-bordered bg-white">
		<thead>
			<tr class="table-header">
				<th>收款账户</th>
				<th>收款金额</th>
				<th>收款时间</th>
			</tr>
		</thead>
		<tbody class="table-row">
			#set(orderFundList = receiptOrder.orderFundList??)
			#for(x : orderFundList)
			<tr>
				<td>#(x.balanceAccount.name??)</td>
				<td>#number(x.amount, "#.##")</td>
				<td>#date(x.fund_time, "yyyy-MM-dd")</td> 
			</tr>
			#end
			<tr>
			<td class="text-end">收款合计</td>
			<td><span class="fw-bold text-secondary">￥#number(receiptOrder.amount, "#.##")</span></td>
			<td></td>
			</tr>
		</tbody>
	</table>
	</div>
	</div>

#set(orderRefList = receiptOrder.orderRefList)
#if(orderRefList && orderRefList.size() > 0)
<div class="row">
	<div class="col">
		<span class="fw-bold text-secondary">核销单据列表</span>
	</div>
</div>
<div class="row mt-1">
	<div class="col">
		<table class="table table-hover table-bordered bg-white">
			<thead>
				<tr class="table-header">
					<th>单据日期</th>
					<th>单据编号</th>
					<th>应收金额</th>
					<th>已收金额</th>
					<th>未收金额</th>
					<th>本次收款金额</th>
					<th>优惠金额</th>
				</tr>
			</thead>
			<tbody class="table-row">
			#for(x : orderRefList)
			#set(saleOrder = x.saleOrder)
				<tr>
					<td>#date(saleOrder.order_time, "yyyy-MM-dd")</td>
					<td>#(saleOrder.order_code??)</td>
					<td>#number(saleOrder.amount, '#.##')</td>
					<td>#number(saleOrder.paid_amount, '#.##')</td>
					<td>#number(saleOrder.amount-saleOrder.paid_amount, '#.##')</td>
					<td class="fw-bold text-success">#number(x.amount, '#.##')</td>
					<td class="fw-bold text-success">#number(x.discount_amount, '#.##')</td>
				</tr>
			#end
			</tbody>
		</table>
	</div>
</div>
#end

	<div class="card ">
		<div class="card-body" style="padding: 1rem 1rem;">
			<div class="row">
				<div class="col-2">
					<span class="text-secondary">核销金额：</span><span>#number(receiptOrder.order_amount??, "#.##")</span>
			</div>
			<div class="col-2">
					<span class="text-secondary">优惠金额：</span><span>#number(receiptOrder.discount_amount??0, "#.##")</span>
			</div>
			<div class="col-2">
					<span class="text-secondary">实际核销：</span><span class="badge bg-success">#number(receiptOrder.check_amount??, "#.##")</span>
			</div>
			</div>
			<hr class="row-hr" />
			<div class="row">
				<div class="col">
					<span class="text-secondary">备注：</span><span>#(receiptOrder.remark??)</span>
				</div>
				<div class="col text-end" id="receiptOrder_order_img_list_preview">
					#for(thumb : receiptOrder.orderImgList)
					<img class="rounded" src="#(resourceUploadDomain)#(thumb)" layer-src="#(resourceUploadDomain)#(thumb)" style="width:30px" >
					#end
				</div>
			</div>
		</div>
	</div>
	</div>
	
</div>


<script type="application/javascript">
	
	
$(function() {
	// 初始化bootstrap相关组件
	common.initBootstrap();
	
	beekit.photos("#receiptOrder_order_img_list_preview");
	
});

receiptOrder.showPrint = function(orderId) {
	beekit.modal("/fund/book/receiptOrder/showPrint?id="+orderId);
}

</script>